package com.beesphere.excel.writer.style.resolvers;

import java.lang.reflect.Method;

import org.apache.poi.ss.usermodel.BuiltinFormats;

import com.beesphere.excel.writer.impls.WorkbookContext;

public class DataFormatResolver extends MethodBasedStyleResolver {

	private static final long serialVersionUID = 6105342542175072911L;
	
	public DataFormatResolver (Method method) {
		super(method);
	}
	
	@Override
	protected Object getValue (WorkbookContext workbookContext, Object applyTo, Object value) {
		if (workbookContext.getDataFormat () != null) {
			return workbookContext.getDataFormat ().getFormat((String)value);
		}
		return (short)BuiltinFormats.getBuiltinFormat ((String) value);
	}

}
